<?php

use Illuminate\Database\Seeder;

class TravelsReplyTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $travels_ids = \App\Model\Travels::all()->pluck('id')->toArray();

        $user_ids = \App\Model\User::all()->pluck('id')->toArray();

        $faker = app(Faker\Generator::class);

        $travels_replies = factory(\App\Model\TravelsReply::class)->times(1000)->make()->each(function ($value)
            use($travels_ids,$user_ids,$faker)
        {
            $value->travels_id = $faker->randomElement($travels_ids);
            $value->user_id = $faker->randomElement($user_ids);
        });

        \App\Model\TravelsReply::insert($travels_replies->toArray());
    }
}
